/**
 * 
 * 深圳市店联电子商务有限公司
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TResume;
import com.ruipengkj.bean.TTexperience;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TTexperienceDao;
import com.ruipengkj.service.TTexperienceService;
/**
 * 说明：
 * 招聘管理Service层接口实现
 * @Author：朱攀
 * @Date：2012-07-25
 */
@Service
public class TTexperienceServiceImpl implements TTexperienceService{
	@Resource
	private TTexperienceDao tTexperienceDao;//DAO层
	//查询所有
	@Override
	public List<TTexperience> findService(TTexperience entity) throws Exception {
		String hql = "select o from TTexperience o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tTexperienceDao.findDao(hql, whereHQL.toString(), param, orderby);
	}
	//根据ID翻页查询
	@Override
	public PageModel<TTexperience> getScrollService(int firstResult,
			int maxResult, TTexperience entity) throws Exception {
		String hql = "select o from TTexperience o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tTexperienceDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	//修改
	@Override
	public void modifyService(TTexperience entity) throws Exception {
		tTexperienceDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TTexperience entity) throws Exception {
		tTexperienceDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		tTexperienceDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TTexperience getByIdService(String id) throws Exception {
		return tTexperienceDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TTexperience entity) throws Exception {
		tTexperienceDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TTexperience entity) throws Exception {
		return tTexperienceDao.saveRetDao(entity);
	}
	public TTexperienceDao getTTexperienceDao() {
		return tTexperienceDao;
	}
	public void setTTexperienceDao(TTexperienceDao texperienceDao) {
		tTexperienceDao = texperienceDao;
	}
	@Override
	public PageModel<TTexperience> getTTexperienceList(int firstResult,
			int maxResult, TResume entity) throws Exception {
		
		String hql = "select o from TTexperience o left join o.TResume as o2";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(entity.getResumeID()!=null&&!entity.getResumeID().equals("")){
				whereHQL.append("o.TResume.resumeID=o2.resumeID and o2.resumeID = ?");
				param.add(entity.getResumeID());
			}
		}
		
 		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tTexperienceDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	
	
}